package DemoText;
/**
 * 错误票据
 */

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class LuoGuP8598 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int tmp = in.nextInt();
        in.nextLine();
        String ret = "";
        int m = 0, n = 0;
        while (tmp-- != 0)
            ret += in.nextLine() + " ";
        String[] str = ret.split(" ");
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0 ; i < str.length ; i++)
            list.add(Integer.parseInt(str[i]));
        Collections.sort(list);
        for (int i = 1; i < list.size(); i++) {
            if (list.get(i) - list.get(i - 1) == 2) m = list.get(i) - 1;
            if (list.get(i) - list.get(i - 1) == 0) n = list.get(i);
        }
        System.out.println(m + " " + n);
        in.close();
    }
}
